package com.qianji.comment;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
/**
 * @Author 钟丽诗
 * @Date 2021.3.10
 *
 */
@Slf4j
@Repository
public class SendEmailComment {

    @Value("${spring.mail.username}")
    private String sender;

    @Resource
    private JavaMailSender jms;

    public void sendEmail(String receiver, String title, String content) {

        SimpleMailMessage smm = new SimpleMailMessage();

        log.info("发送者：{}",sender);
        smm.setFrom(sender);

        log.info("接受者：{}",receiver);
        smm.setTo(receiver);

        //标题
        smm.setSubject(title);

        //内容
        smm.setText(content);

        jms.send(smm);

    }

}
